package com.tsl.reggie.aop;

import com.tsl.reggie.common.R;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.Set;

@Component
@Aspect
public class DeleteDishRedisAop {
    @Autowired
    private RedisTemplate redisTemplate;
    @Around("@annotation(com.tsl.reggie.anno.DeleteDishRedis)")
    public R<String> deleteRedis(ProceedingJoinPoint point) throws Throwable {

        Set dish = redisTemplate.keys("dish*");
        redisTemplate.delete(dish);
        Object proceed = point.proceed();
        return (R) proceed;

    }
}
